package com.mlog.njyjy.ndop.msg.common.domain;

import com.jfinal.plugin.activerecord.Model;
import com.mlog.njyjy.ndop.msg.common.domain.core.Timeable;
import com.mlog.njyjy.ndop.msg.common.support.Constants;
import com.mlog.njyjy.ndop.share.sql.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author zyz
 * @version v1.0, 2020/8/11
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Table(prefix = Constants.TBL_MSG_PREFIX,
        uniques = {@TableUnique(columns = {"name", "typeName", "times"})},
        comment = "消息流程表")
public class Flow extends Model<Flow> implements Timeable {

    @Id
    private Long id;

    @Column(comment = "流程名", nullable = false)
    private String name;

    @Column(comment = "业务类型名", nullable = false)
    private String typeName;

    @Column(comment = "产品时次")
    private String times = "";

    @Join(joinedBy = "id", mappedBy = "flowId")
    private List<NodeItem> items;

    @Column(updatable = false)
    private LocalDateTime createAt;

    private LocalDateTime updateAt;

    public List<NodeItem> getItems() {
        return items;
    }
}
